(*
	sendVideo cmd,opt - Send the command string cmd to the video player and wait for an
		acknowledgement. In the case of some players, the opt parameter supplies additional
		information or options on how to proceed:

			player		opt meaning
			ΡΡΡΡ		ΡΡΡΡΡΡΡΡ
			Sony			If present, don't clear previous commands.
			Hitachi		If present, wait for this as acknowledgement from player, rather than waiting
							for the command character sent.

		In the case of the Pioneer 6000 player, numeric parameters embedded in the cmd should be
		surrounded with periods (as in '.1000.'). sendVideo will then translate to the appropriate
		input to the player.

	To compile and link this file using Macintosh Programmer's Workshop,

		pascal -w sendVideo.p

		link -m ENTRYPOINT -o HyperCommands -rt XCMD=8005 -sn Main=sendVideo ¶
			sendVideo.p.o "{MPW}"Libraries:interface.o "{MPW}"PLibraries:PasLib.o

	Copyright © 1987,88 Apple Computer, Inc.

	9/87 - Initial coding by Harry R. Chesley.
	2/88 - Changed for new interface specification by Harry R. Chesley.
*)

{$R-}

{$S sendVideo } 	{ Segment name must be the same as the command name. }

unit DummyUnit;

interface

uses MemTypes, QuickDraw, OSIntf, HyperXCmd;

procedure EntryPoint(paramPtr: XCmdPtr);
	
implementation

type

Str31 = String[31];

procedure sendVideo(paramPtr: XCmdPtr); forward;

procedure EntryPoint(paramPtr: XCmdPtr);

	begin
		sendVideo(paramPtr);
	end;

procedure sendVideo(paramPtr: XCmdPtr);

	var numberOfParms: integer;
		str, str2: str255;

	{$I XCmdGlue.inc}

	procedure Fail(errMsg: Str255); { set theResult and quit }
		begin
			paramPtr^.returnValue := PasToZero(errMsg);
			exit(sendVideo);
		end;

	{$I VideoUtil.inc}

	begin
		numberOfParms := paramPtr^.paramCount;
		if (numberOfParms <> 1) and (numberOfParms <> 2) then Fail('parameter count is not 1 or 2');

		GetStrParm(1,str);													{ First parameter is the string to send. }
		if numberOfParms > 1 then GetStrParm(2,str2)		{ Second is the optional parameter for this player. }
		else str2 := '';

		{ Clear out any pending input. }
		EvalAndDispose('RecvUpTo(empty,0,empty)');

		{ Send it... }
		videoCmd('sendCmd',Concat('"',str,'","',str2,'"'));
	end;

end.
